package com.woniuxueyuan.Controller;

import com.woniuxueyuan.entity.dto.OrderParamDTO;
import com.woniuxueyuan.service.OrderService;
import com.woniuxueyuan.util.ResponseData;
import com.woniuxueyuan.util.ResponseEnum;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;
    @PostMapping("/addOrder")
    public ResponseData addOrder(@RequestBody  OrderParamDTO orderParamDTO){
        try {
            //校验参数
            if(orderParamDTO.getAddrId()==null|| CollectionUtils.isEmpty(orderParamDTO.getIds()))
                return ResponseData.fail(ResponseEnum.PARAMERROR);
            return orderService.addOrder(orderParamDTO);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException();
        }
    }
}
